package com.zhl.config;

import feign.Client;
import feign.Request;
import feign.Response;
import org.springframework.web.servlet.DispatcherServlet;

import java.io.IOException;

public class LocalBlockingFeignClient implements Client {

    private final DispatcherServlet dispatcherServlet;
    public LocalBlockingFeignClient(DispatcherServlet dispatcherServlet) {
        this.dispatcherServlet = dispatcherServlet;
    }

    @Override
    public Response execute(Request request, Request.Options options) throws IOException {

        /**
         * 1. 根据仅有的这个request里面的url去找对应的controller以及method
         * 2. 根据这个method接受的参数，从request里面获取值进行填充
         * 3. 执行反射调用 得到结果
         * 4. 根据这个结果构建一个Response 进行返回
         *
         *
         * 尝试复用SpringMvc的HandlerMapping handlerAdapeter来处理
         * 难点在于
         * 1. 匹配HandlerMapping的参数是HttpServletRequest 细节太多
         * 2. 返回的应该是HttpServletResponse 要转换成Response 也会涉及到一些细节
         */

//        org.apache.catalina.connector.Request re = new org.apache.catalina.connector.Request();
//        RequestFacade requestFacade = new RequestFacade();

        System.out.println("hello");
        return null;
    }
}
